#include "BangoProfile.h"

BangoProfile::BangoProfile()
{
    _profilePosted = false;
}

BangoProfile::~BangoProfile()
{

}

BangoProfile::BangoProfile(int sdkType,
                           QString sdkVersion,
                           QString applicationId,
                           QString applicationType,
                           QString applicationChannel,
                           QString applicationVersion,
                           QString userId,
                           int sessionRestartTime,
                           int connectionType,
                           bool isRoaming,
                           QString locationSource,
                           QString operatorShortName,
                           QString operatorName,
                           QString operatorCountryIso,
                           QString simOperator,
                           QString brand,
                           QString device,
                           QString model,
                           QString product,
                           QString version,
                           QString buildId,
                           QString operatorConnectionType
                           )
{

    SetValues(sdkType, sdkVersion, applicationId, applicationType, applicationChannel, applicationVersion, userId, sessionRestartTime, connectionType, isRoaming,
    locationSource, operatorShortName, operatorName, operatorCountryIso, simOperator, brand, device, model, product, version, buildId, operatorConnectionType);

    UpdateLocationValues(0,0,0,0);
}

void BangoProfile::SetValues(int sdkType,
                           QString sdkVersion,
                           QString applicationId,
                           QString applicationType,
                           QString applicationChannel,
                           QString applicationVersion,
                           QString userId,
                           int sessionRestartTime,
                           int connectionType,
                           bool isRoaming,
                           QString locationSource,
                           QString operatorShortName,
                           QString operatorName,
                           QString operatorCountryIso,
                           QString simOperator,
                           QString brand,
                           QString device,
                           QString model,
                           QString product,
                           QString version,
                           QString buildId,
                           QString operatorConnectionType
                           )

{
    _sdkType = sdkType;
    _sdkVersion = sdkVersion;
    _applicationId = applicationId;
    _applicationType = applicationType;
    _applicationChannel = applicationChannel;
    _applicationVersion = applicationVersion;
    _userId = userId;
    _sessionRestartTime = sessionRestartTime;
    _connectionType = connectionType;
    _isRoaming = isRoaming;
    _operator = operatorShortName;
    _operatorName = operatorName;
    _operatorCountryIso = operatorCountryIso;
    _simOperator = simOperator;
    _brand = brand;
    _device = device;
    _model = model;
    _product = product;
    _version = version;
    _buildId = buildId;
    _operatorConnectionType = operatorConnectionType;
    _locationSource = locationSource;
    _profilePosted = false;

}

void BangoProfile::UpdateLocationValues(double locationAltitude,
                                        double locationLatitude,
                                        double locationLongitude,
                                        float locationAccuracy)
{
    _locationAltitude = locationAltitude;
    _locationLatitude = locationLatitude;
    _locationLongitude = locationLongitude;
    _locationAccuracy = locationAccuracy;
}


QVariantMap BangoProfile::GetProfileDetails()
{
    QVariantMap profileDetails;

    profileDetails.insert(BangoFieldNames::POST_SDKTYPE, _sdkType);
    profileDetails.insert(BangoFieldNames::POST_SDKVERSION, _sdkVersion);
    profileDetails.insert(BangoFieldNames::POST_CONNECTIONTYPE, BangoStatic::ConnectionType(_connectionType));
    profileDetails.insert(BangoFieldNames::POST_OPERATORCONNECTIONTYPE, _operatorConnectionType);
    profileDetails.insert(BangoFieldNames::POST_ISROAMING, QVariant(_isRoaming));

    profileDetails.insert(BangoFieldNames::POST_LOCATIONSOURCE, _locationSource);
    profileDetails.insert(BangoFieldNames::POST_LOCATIONACCURACY, QVariant(_locationAccuracy));
    profileDetails.insert(BangoFieldNames::POST_LOCATIONALTITUDE, QVariant(_locationAltitude));
    profileDetails.insert(BangoFieldNames::POST_LOCATIONLATITUDE, QVariant(_locationLatitude));
    profileDetails.insert(BangoFieldNames::POST_LOCATIONLONGITUDE, QVariant(_locationLongitude));

    profileDetails.insert(BangoFieldNames::POST_APPLICATIONID, _applicationId);
    profileDetails.insert(BangoFieldNames::POST_APPLICATIONCHANNEL, _applicationChannel);
    profileDetails.insert(BangoFieldNames::POST_APPLICATIONTYPE, _applicationType);
    profileDetails.insert(BangoFieldNames::POST_APPLICATIONVERSION, _applicationVersion);
    profileDetails.insert(BangoFieldNames::POST_USERID, _userId);
    profileDetails.insert(BangoFieldNames::POST_SESSIONRESTARTTIME, QVariant(_sessionRestartTime));

    profileDetails.insert(BangoFieldNames::POST_OPERATOR, _operator);
    profileDetails.insert(BangoFieldNames::POST_OPERATORNAME, _operatorName);
    profileDetails.insert(BangoFieldNames::POST_COUNTRYISO, _operatorCountryIso);
    profileDetails.insert(BangoFieldNames::POST_DEVICEBRAND, _brand);
    profileDetails.insert(BangoFieldNames::POST_DEVICEMAKE, _brand);
    profileDetails.insert(BangoFieldNames::POST_DEVICEMODEL, _device);
    profileDetails.insert(BangoFieldNames::POST_SIM, _simOperator);
    profileDetails.insert(BangoFieldNames::POST_PRODUCT, _product);
    profileDetails.insert(BangoFieldNames::POST_OPERATINGSYSTEMVERSION, _version);
    profileDetails.insert(BangoFieldNames::POST_DEVICEVERSION, _model);

    profileDetails.insert(BangoFieldNames::POST_OPERATINGSYSTEM, BangoStatic::GetOperatingSystemName());


    return profileDetails;
}
